package com.example.myproject.quartz;

import org.quartz.*;
import org.springframework.stereotype.Service;

import java.util.Date;

@DisallowConcurrentExecution //依赖之后，就变成串行了，cron 没用了。
@PersistJobDataAfterExecution
public class TestJob implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        System.out.println("===========成功运行定时任务==========="+Thread.currentThread().getName()+",date:"+new Date());
        System.out.println(jobExecutionContext.getJobDetail().getKey());
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
